<?php

namespace app\model\group_activity;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 团体活动-发布活动
 */
class GroupActivityTaskModel extends BaseModel
{
    protected $name = 'group_activity_task';

    /**
     * 活动类型
     * @return BelongsTo
     */
    public function typeName(): BelongsTo
    {
        return $this->belongsTo(GroupActivityTypeModel::class, 'type_id')->bind([
            'type_name' => 'name'
        ]);
    }

    /**
     * 发布人
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name' => 'name',
            'role_name'
        ]);
    }

    /**
     * 活动部门
     * @return HasMany
     */
    public function taskDepartment(): HasMany
    {
        return $this->hasMany(GroupActivityTaskDepartmentModel::class,'task_id');
    }

    /**
     * 活动测评量表
     * @return HasMany
     */
    public function taskRatingScale(): HasMany
    {
        return $this->hasMany(GroupActivityTaskRatingScaleModel::class,'task_id');
    }

    /**
     * 活动评论
     * @return HasMany
     */
    public function taskComment(): HasMany
    {
        return $this->hasMany(GroupActivityTaskCommentModel::class,'task_id');
    }

    /**
     * 活动图片
     * @return HasMany
     */
    public function taskImg(): HasMany
    {
        return $this->hasMany(GroupActivityTaskImgModel::class,'task_id');
    }

}